<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Image-only Example - Record Plugin for Video.js</title>

  <link href="../node_modules/video.js/dist/video-js.min.css" rel="stylesheet">
  <link href="../dist/css/videojs.record.css" rel="stylesheet">
  <link href="assets/css/examples.css" rel="stylesheet">

  <script src="../node_modules/video.js/dist/video.min.js"></script>
  <script src="../node_modules/webrtc-adapter/out/adapter.js"></script>

  <script src="../dist/videojs.record.js"></script>

  <style>
  /* change player background color */
  #myImage {
      background-color: #efc3e6;
  }
  </style>
</head>
<body>

<video id="myImage" playsinline class="video-js vjs-default-skin"></video>

<script>
/* eslint-disable */
var options = {
    controls: true,
    fluid: false,
    bigPlayButton: false,
    controlBar: {
        volumePanel: false,
        fullscreenToggle: false
    },
    // dimensions of the video.js player
    width: 640,
    height: 480,
    plugins: {
        record: {
            debug: true,
            imageOutputType: 'dataURL',
            imageOutputFormat: 'image/png',
            imageOutputQuality: 0.92,
            image: {
              // image media constraints: set resolution of camera
              width: { min: 640, ideal: 640, max: 1280 },
              height: { min: 480, ideal: 480, max: 920 }
            },
            // dimensions of captured video frames
            frameWidth: 640,
            frameHeight: 480
        }
    }
};

var player = videojs('myImage', options, function() {
    // print version information at startup
    var msg = 'Using video.js ' + videojs.VERSION +
        ' with videojs-record ' + videojs.getPluginVersion('record');
    videojs.log(msg);
});

// error handling
player.on('deviceError', function() {
    console.warn('device error:', player.deviceErrorCode);
});

player.on('error', function(element, error) {
    console.error(error);
});

// snapshot is available
player.on('finishRecord', function() {
    // the blob object contains the image data that
    // can be downloaded by the user, stored on server etc.
    console.log('snapshot ready: ', player.recordedData);
});

player.on('retry', function() {
  console.log('retry');
});
</script>

</body>
</html>
